﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace NJL.WebManage
{
    public partial class ChangePassword :BasePage
    {
        NJL.BLL.NJL_SYS_ADMIN bllAdmin = new BLL.NJL_SYS_ADMIN();
        NJL.Model.NJL_SYS_ADMIN modelAdmin = new Model.NJL_SYS_ADMIN();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {  
            string oldpwd=FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPwd.Text.Trim(),"MD5");
            string newpwd=FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPwd.Text.Trim(),"MD5");
            modelAdmin = bllAdmin.GetModel(USER_ID);
            if (modelAdmin.ADMIN_PASSWORD_MD5 != oldpwd)
            {
                Royalsoft.Common.MessageBox.Show(this, "您输入的原始密码不正确，请重新输入");
                return;
            }
            modelAdmin.ADMIN_PASSWORD_MD5 = newpwd;
            modelAdmin.ADMIN_PASSWORD = txtNewPwd.Text.Trim();
            if (bllAdmin.Update(modelAdmin))
            {
                Royalsoft.Common.MessageBox.Show(this, "密码修改成功");
            }
           

        }
    }
}